#include "Customer.h"

using namespace std;
Customer::Customer()
{
    memset(name,0,sizeof(name));
    memset(address, 0, sizeof(address));
    memset(job, 0, sizeof(job));
    //ctor
}

Customer::~Customer()
{
    //dtor
}

int Customer::add_to_sql(MYSQL *con) {
    char insert_query[200];
    sprintf(insert_query, "INSERT INTO member SET name='%s',address='%s',job='%s'", name, address, job);
    if(!mysql_query(con, insert_query)) {
        printf("OK. %s's member id is %03d\n", name, mysql_insert_id(con));
        return 1;
    }
    else puts("Insert Failed");
    return 0;
}

int Customer::set_address(char *taddress) {
    strcpy(address, taddress);
    return 0;
}

int Customer::set_name(char *tname) {
    strcpy(name, tname);
    return 0;
}

int Customer::set_job(char *tjob) {
    strcpy(job, tjob);
}
